
clear all
set more off

global data "COMPLETE YOUR DIRECTORY HERE \data"
global output "COMPLETE YOUR DIRECTORY HERE \output"

use "$data/cleaned_ind_daily.dta", clear

destring monthincomeifwork whrsifwork hrwageifwork, replace force

gen t=.
replace t=1 if qtr==12019
replace t=2 if qtr==22019
replace t=3 if qtr==32019
replace t=4 if qtr==42019
replace t=5 if qtr==12020
replace t=6 if qtr==32020
replace t=7 if qtr==42020

label define quarter_lab 1 "Q1-2019" 2 "Q2-2019" 3 "Q3-2019" 4 "Q4-2019" 5 "Q1-2020" 6 "Q3-2020" 7 "Q4-2020"
label values t quarter_lab

egen id2=group(id)
egen t2=group(int_date)

drop if telephone==1
drop if missing_emif==1

xtset id2 t
keep if status1=="active"

/*
Descriptive statistics: labor
*/

**All periods
preserve
replace hrwage=. if hrwage==0
collapse (mean) whrs hrwage covid_exp_w covid_exp_mx  [aw=weight], by(mx_mun t)
sum whrs hrwage covid_exp_w covid_exp_mx
estpost summarize whrs hrwage covid_exp_w covid_exp_mx
esttab using $output\table_1.csv , cells("mean(fmt(2)) sd(fmt(2)) count(fmt(0))") noobs replace
restore

**Pre Covid
preserve
keep if t<=5
replace hrwage=. if hrwage==0
collapse (mean) whrs hrwage covid_exp_w covid_exp_mx  [aw=weight], by(mx_mun t)
sum whrs hrwage covid_exp_w covid_exp_mx
estpost summarize whrs hrwage covid_exp_w covid_exp_mx
esttab using $output\table_1.csv , cells("mean(fmt(2)) sd(fmt(2)) count(fmt(0))") noobs append
restore

**Post Covid
preserve
keep if t>5
replace hrwage=. if hrwage==0
collapse (mean) whrs hrwage covid_exp_w covid_exp_mx  [aw=weight], by(mx_mun t)
sum whrs hrwage covid_exp_w covid_exp_mx
estpost summarize whrs hrwage covid_exp_w covid_exp_mx
esttab using $output\table_1.csv , cells("mean(fmt(2)) sd(fmt(2)) count(fmt(0))") noobs append
restore


/*
Descriptive statistics: remittances
*/

clear all
use "$data/cleaned_ind_daily.dta", clear
destring monthincomeifwork whrsifwork hrwageifwork, replace force

gen t=.
replace t=1 if qtr==12019
replace t=2 if qtr==22019
replace t=3 if qtr==32019
replace t=4 if qtr==42019
replace t=5 if qtr==12020
replace t=6 if qtr==32020
replace t=7 if qtr==42020

label define quarter_lab 1 "Q1-2019" 2 "Q2-2019" 3 "Q3-2019" 4 "Q4-2019" 5 "Q1-2020" 6 "Q3-2020" 7 "Q4-2020"
label values t quarter_lab

egen id2=group(id)
egen t2=group(int_date)

drop if telephone==1
drop if missing_emif==1

xtset id2 t

keep if status1=="active"

**Descriptive statistics

cd "$output"

**All periods
preserve
collapse (mean) remit_mpesos_r remit_musd_r, by(mx_mun t)
estpost summarize remit_mpesos_r remit_musd_r
esttab using "table_1.csv", cells("mean(fmt(2)) sd(fmt(2)) count(fmt(0))") noobs append
restore

**Pre Covid
preserve
keep if t<=5
collapse (mean) remit_mpesos_r remit_musd_r, by(mx_mun t)
estpost summarize remit_mpesos_r remit_musd_r
esttab using "table_1.csv", cells("mean(fmt(2)) sd(fmt(2)) count(fmt(0))") noobs append
restore

**Post Covid
preserve
keep if t>5
collapse (mean) remit_mpesos_r remit_musd_r, by(mx_mun t)
estpost summarize remit_mpesos_r remit_musd_r
esttab using "table_1.csv", cells("mean(fmt(2)) sd(fmt(2)) count(fmt(0))") noobs append
restore




